package com.itheima.blockingquene.shengchanxiaofei;

import com.itheima.shengchanxiaofei.Desk;

import java.util.concurrent.ArrayBlockingQueue;

/*
消费者

套路
    1.死循环
    2.同步代码块
    3.判断是否到数了
    4.判断是否该吃|生产了

 */
public class Foodie extends Thread{

    private ArrayBlockingQueue<String> list;

    public Foodie() {
    }

    public Foodie(ArrayBlockingQueue<String> list) {
        this.list = list;
    }
    @Override
    public void run() {
        while (true) {
            try {
                list.take();
                System.out.println("吃货吃了一个");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
